﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.TaskScheduling.Migrations
{
    /// <inheritdoc />
    public partial class rm_table_sample_testitem : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "TS_SampleTestItem",
                schema: "TaskScheduling");

            migrationBuilder.AddColumn<long>(
                name: "StandardTestTaskId",
                schema: "TaskScheduling",
                table: "TS_StandardTestItem",
                type: "bigint",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_TS_StandardTestItem_StandardTestTaskId",
                schema: "TaskScheduling",
                table: "TS_StandardTestItem",
                column: "StandardTestTaskId");

            migrationBuilder.AddForeignKey(
                name: "FK_TS_StandardTestItem_TS_StandardTestTasks_StandardTestTaskId",
                schema: "TaskScheduling",
                table: "TS_StandardTestItem",
                column: "StandardTestTaskId",
                principalSchema: "TaskScheduling",
                principalTable: "TS_StandardTestTasks",
                principalColumn: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_TS_StandardTestItem_TS_StandardTestTasks_StandardTestTaskId",
                schema: "TaskScheduling",
                table: "TS_StandardTestItem");

            migrationBuilder.DropIndex(
                name: "IX_TS_StandardTestItem_StandardTestTaskId",
                schema: "TaskScheduling",
                table: "TS_StandardTestItem");

            migrationBuilder.DropColumn(
                name: "StandardTestTaskId",
                schema: "TaskScheduling",
                table: "TS_StandardTestItem");

            migrationBuilder.CreateTable(
                name: "TS_SampleTestItem",
                schema: "TaskScheduling",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false),
                    TestItem = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    StandardTestTaskId = table.Column<long>(type: "bigint", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TS_SampleTestItem", x => new { x.Id, x.TestItem });
                    table.ForeignKey(
                        name: "FK_TS_SampleTestItem_TS_StandardTestTasks_StandardTestTaskId",
                        column: x => x.StandardTestTaskId,
                        principalSchema: "TaskScheduling",
                        principalTable: "TS_StandardTestTasks",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_TS_SampleTestItem_StandardTestTaskId",
                schema: "TaskScheduling",
                table: "TS_SampleTestItem",
                column: "StandardTestTaskId");
        }
    }
}
